﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SistemaControleOrcamentario
{
    public partial class frmInicio : Form
    {
        public frmInicio()
        {
            InitializeComponent();
            decimal _valor = DataLayer.Model.Lancamento.GetAll().Sum(p => p.Valor);
            lblSaldo.Text = "Saldo Total : " + _valor.ToString("c");

            if (_valor < 0)
            {
                lblSaldo.ForeColor = Color.Red;
            }
        }

        private void entradaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            (new Lancamento(true)).Show();
        }

        private void categoriasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            (new Categoria()).Show();
        }

        private void lançamentosToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            (new RelLancamento()).Show();
        }

        private void saidaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            (new Lancamento(false)).Show();

        }

        private void frmInicio_FormClosing(object sender, FormClosingEventArgs e)
        {
            DataLayer.Core.Server.CreateBackup();
        }

        private void contasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            (new Conta()).Show();
        }

        private void contasSaldoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            (new RelContaSaldo()).Show();
        }

        private void categoriasToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            (new RelCategoria()).Show();
        }

        private void transferênciaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            (new Forms.Transferencia()).Show();
        }

        private void tESTEToolStripMenuItem_Click(object sender, EventArgs e)
        {
            (new Forms.RelLancamentoExport()).Show();
        }
    }
}
